package org.xwb.springcloud.config;


import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.xwb.springcloud.constant.MqConstant;

/**
 * 创建RabbitMQ的配置类
 *
 * @author 10564
 */
@Configuration
public class RabbitmqDirectConfig {
    @Bean
    public Queue directQueueOne() {
        return new Queue(MqConstant.DIRECT_QUEUE_ONE);
    }

    @Bean
    public Queue directQueueTwo() {
        return new Queue(MqConstant.DIRECT_QUEUE_TWO);
    }

    @Bean
    public DirectExchange directExchange() {
        return new DirectExchange(MqConstant.DIRECT_EXCHANGE_NAME);
    }

    @Bean
    public Binding directExchangeBindOne() {
        return BindingBuilder.bind(directQueueOne()).to(directExchange()).with(MqConstant.DIRECT_ROUTING_KEY_ONE);
    }

    @Bean
    public Binding directExchangeBindTwo() {
        return BindingBuilder.bind(directQueueTwo()).to(directExchange()).with(MqConstant.DIRECT_ROUTING_KEY_TWO);
    }
}